<?php
/**
 * Created by PhpStorm.
 * User: nightelf
 * Date: 2020/6/22
 * Time: 15:58
 */

namespace App\Http\Model;

use Illuminate\Support\Facades\DB;

class SupplierOrdersReceivingModel
{
    const TABLE = 'supplier_orders_receiving';

    public function insert(array $data)
    {
        return DB::table(self::TABLE)->insertGetId($data);
    }

    public function lists(array $param)
    {
        return DB::table(self::TABLE)
            ->where(function ($query) use ($param){
                if (!empty($param['orderId'])){
                    $query->where('orderId',$param['orderId']);
                }
            })
            ->orderBy('receivingTime')
            ->get()->toArray();
    }
}